package com.pounds.control;

import com.pounds.pojo.Meal;
import com.pounds.service.MealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("peaceful/meal")
public class MealControl {

    @Autowired
    private MealService mealService;

    @GetMapping("select")
    public List<Meal> getMealList() {
        return mealService.getMealList();
    }

    @GetMapping("new")
    public String addMeal(int user, String breakfast, String lunch, String dinner, String need, String note) {
        return mealService.addMeal(user, breakfast, lunch, dinner, need, note);
    }

    @GetMapping("delete")
    public String deleteMeal(int id) {
        return mealService.deleteMeal(id);
    }

    @GetMapping("update")
    public String updateMeal(int id, int user, String breakfast, String lunch, String dinner, String need, String note) {
        return mealService.updateMeal(id, user, breakfast, lunch, dinner, need, note);
    }
}
